package com.alex.seo.service.sitebridge;

import java.net.MalformedURLException;

import com.alex.seo.domain.site.Site;
import com.alex.seo.domain.site.Wordpress;
import com.alex.seo.service.sitebridge.SiteBridge;
import com.alex.seo.service.sitebridge.wordpress.WordpressBridge;

public class SiteBridgeLookupService {

	public static SiteBridge lookup(Site site) throws SiteBridgeLookupException {
		try {
			if (site instanceof Wordpress) {
				Wordpress wordpress = (Wordpress) site;
				return new WordpressBridge(wordpress.getUrl() + "/xmlrpc.php", wordpress.getLogin(), wordpress.getPassword());
			} else {
				throw new IllegalArgumentException("Could not lookup site bridge for site: " + site.getClass().getSimpleName());
			}
		} catch (MalformedURLException e) {
			throw new SiteBridgeLookupException(e);
		}
	}

}
